<template>
    <div class="pb_a">
        <van-nav-bar class="head_nb" title="报考指南" left-text="返回" left-arrow @click-left="goBack"/>
        <div class="pt_a">
            <div>
                <van-cell-group v-for="item in guides" :key="item.id">
                    <van-cell :title="item.subjectName" is-link @click="toGuide(item.id)"/>
                </van-cell-group>
            </div>
        </div>
    </div>
</template>

<script>
    import {getGuide} from '../../../api';

    export default {
        name: "GuideList",
        data() {
            return {
                pageNumber: 1,
                pageSize: 10,
                guides: [],
            };
        },
        async created() {
            //异步获取所有的指南内容
            const params = {pageSize: this.pageSize, pageNumber: this.pageNumber};
            const result = await getGuide(params);
            if (result.code === 0) {
                this.guides = result.data;
            }
        },
        methods: {
            goBack() {
                this.$router.back();
            },
            toGuide(id) {
                this.$router.push({
                    name: 'Guide',
                    query: {
                        id: id
                    }
                });
            }
        }
    }
</script>

<style scoped>

</style>
